<?php

class CommDataModel extends Cola_Model {
    protected $_table = "guoce_comm_data";
    protected $_pk = "guoce_key";

    /**
     * 设置CommData
     * 
     * @param unknown_type $guoce_key
     * @param unknown_type $guoce_value
     * @param unknown_type $expire_time
     * @return boolean|Ambigous <boolean, mixed, resource>
     */
    public function setCommData($guoce_key, $guoce_value, $expire_time = 0) {
    	if(empty($guoce_key) || empty($guoce_value)){
    		return false;
    	}
    	$data = array();
    	$data['guoce_key'] = $guoce_key;
    	$data['guoce_value'] = $guoce_value;
    	$data['expire_time'] = $expire_time;
    	return $this->replace($data, $this->_table);
    }
    /**
     * 获取comm_data信息
     * 
     * @param unknown_type $guoce_key
     * @return boolean|Ambigous <multitype:, boolean, mixed, resource>
     */
    public function getCommData($guoce_key){
    	if(empty($guoce_key)){
    		return false;
    	}
    	$sql = "SELECT * FROM {$this->_table} WHERE `guoce_key` = '{$guoce_key}' LIMIT 1";
    	return $this->sql($sql);
    }
    
    /**
     * 删除comm_data信息
     * 
     * @param string $guoce_key
     */
    public function delCommData($guoce_key){
    	if(empty($guoce_key)){
    		return false;
    	}
    	return $this->delete($guoce_key);
    }
}